<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单推送</title>
    <link href="__STATIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/admin/css/animate.min.css" rel="stylesheet">
    <link href="__STATIC__/admin/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/admin/js/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet">
    <link href="__STATIC__/admin/js/layui/css/layui.css"rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-10">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>订单推送</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentForm" method="post" action="{:url('tuisong')}">
                        <input type="hidden" name="id" value="{$order_member}">
                        <div class="form-group" id="role_id" style="">
                            <label class="col-sm-3 control-label">选择推送人员：</label>
                            <div class="input-group col-sm-6">
                                <input type="text" id="tuisong" class="form-control" style="width: 80%">
                                <input type="hidden" id="user_id" value="">
                                <input type="button" class="layui-btn layui-btn-primary" name="add" value="添加" style="height: 35px;margin-left: 10px" />
                            </div>
                        </div>
                        <div id="queryinput" class="form-group" style="">
                            <label class="col-sm-3 control-label">已选择：</label>
                            <table>
                                <thead>
                                <tr class="node_head">
                                    <th width="80%">已选择人员</th>
                                    <th style="text-align: center">操作</th>
                                </tr>
                                </thead>
                                <tbody id="node_role">
                                {foreach $changyong as $v}
                                    <tr>
                                        <td style="height: 38px">
                                            <input type="text" style="height: 35px;font-size: 16px;    width: 500px;" value="{$v.hasmenber.real_name}({$v.hasmenber.phone})[{$v.beizu}]" >
                                            <input name="user_id[]" value="{$v.cid}" type="hidden"></td>
                                        <td >
                                            <a href="javascropt:;" style="display: block; height: 33px;text-align: center;font-size: 14px;padding: 6px;" class="node_x_a" onclick="remove(this)" >删除</a>
                                        </td>
                                    </tr>
                                {/foreach}
                                </tbody>
                            </table>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-8">
                                <!--<input type="button" value="提交" class="btn btn-primary" id="postform"/>-->
                                <button class="btn btn-primary"  type="submit">确认提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="__STATIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/admin/js/content.min.js?v=1.0.0"></script>
<script src="__STATIC__/admin/js/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script>
<script src="__STATIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__STATIC__/admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="__STATIC__/admin/js/layui/layui.js"></script>
<script src="__STATIC__/admin/js/jquery.form.js"></script>
<script src="__STATIC__/admin/js/plugins/ueditor/ueditor.config.js"></script>
<script src="__STATIC__/admin/js/plugins/ueditor/ueditor.all.js"></script>


<style>
    #node_role > tr >  td > .node_x_name{
        width: 100%;
        height: 25px;
        margin-left: 3px;
        margin-top: 3px
    }

    #node_role > tr >  td > .node_x_title{
        width: 100%;
        height: 25px;
        margin-left: 3px;
        margin-top: 3px
    }
    #node_role > tr >  td > .node_x_a{
        margin-left: 3px;
        margin-top: 3px;
        border: 1px solid #cccccc;
        padding: 2px;
        text-align: center;
        color: #ccc;
    }
    #node_role > tr >  td > .node_x_a:hover{
        border: 1px solid #1ab394;
        color: #333;
    }
</style>
<script type="text/javascript">
    var index = '';
    function showStart(){
        index = layer.load(0, {shade: false});
        return true;
    }

    function showSuccess(res){

        layer.ready(function(){
            layer.close(index);
            if(1 == res.code){
                layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                    window.location.href = res.data;
                });
            }else if(111 == res.code){
                window.location.reload();
            }else{
                layer.msg(res.msg, {anim: 6});
            }
        });
    }


    $(document).ready(function(){
        // 添加角色
        var options = {
            beforeSubmit:showStart,
            success:showSuccess
        };

        $('#commentForm').submit(function(){
            $(this).ajaxSubmit(options);
            return false;
        });


        // 上传图片
        layui.use('upload', function(){

        });

        $("input[name='add']").click(function (e)
        {
            var user = $('#tuisong').val();
            var user_id = $('#user_id').val();
            if (user_id == '' || user == ''){
                layer.msg('请选择用户');
                return false;
            }
            $('#tuisong').val("");
            var str = '<tr style="height: 38px">' +
                '<td><input type="text" style="height: 35px;font-size: 16px;width: 500px;" value="'+user+'" ><input name="user_id[]" value="'+user_id+'" type="hidden"></td>\n' +
                '<td ><a href="javascropt:;" style="display: block; height: 33px;text-align: center;font-size: 14px;padding: 6px;" class="node_x_a" onclick="remove(this)" >删除</a></td></tr>';
            $('#node_role').append(str);

            return false;
        });

        //获取会员
        $("#tuisong").focus(function(){
            var indext = layer.open({
                type:2,
                title:'请选择角色' ,
                area: ['800px','600px'] ,
                btn:['确定','取消'],
                content: "{:url('/admin/members/userlist')}",
                yes: function (layero, index) {
                    var newpsw = window[index.find('iframe')[0]['name']];

                    var value=newpsw.getChoseId();
                    var  arr = value.split('_');
                    $('#tuisong').val(arr[1]+'('+arr[2]+')');
                    $('#user_id').val(arr[0]);
                    layer.close(indext)
                },
                btn2: function(index, layero){
                    layer.close(indext)
                }
            });
        });

    });
    function remove(that) {
        layer.confirm('确定删除吗？', {
            btn: ['确定','再想想...'] //按钮
        }, function(index){
            layer.close(index);
            $(that).parent().parent().remove()
        });

    }
    // 表单验证
    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
</script>
</body>
</html>
